Current Location: Home> Function Categories> filter_var

filter_var

Filter a variable using a specific filter
Name:filter_var
Category:Filter
Programming Language:php
One-line Description:Get a variable and filter it.

Definition and usage

filter_var() function filters variables through the specified filter.

If successful, the filtered data is returned, and if failed, false.

实例

<?php
if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL))
 {
 echo("E-mail is not valid");
 }
else
 {
 echo("E-mail is valid");
 }
?>

输出类似:

E-mail is not valid

grammar

 filter_var ( variable , filter , options )
parameter describe
variable Required. Specify the variables to be filtered.
filter Optional. Specifies the ID of the filter to be used.
options Specifies an array containing flags/options. Check each filter for possible flags and options.
Similar Functions
Popular Articles